// 接口调用
/*
  1：下载axios
  2:导入axios
  3:调用axios
  4:定义axios的参数与接口返回值的类型
    a:参数
    b:返回值   axios<T>
    c:存储的变量要定义

*/

import axios from 'axios'

type channelsApi = {
  data: {
    channels: ListType
  }
  message: string
}
type ListType = { id: number; name: string }[]
let list: ListType = []
const getList = async () => {
  const res = await axios<channelsApi>({
    url: 'http://geek.itheima.net/v1_0/channels'
  })
  list = res.data.data.channels
  list.forEach(item => {
    console.log(item.name)
  })
}
getList()

export {}
